package domain

type AnnotationInfo struct {
	Name       string
	Attributes []*AnnotationAttribute
}

func NewAnnotationInfo() *AnnotationInfo {
	it := new(AnnotationInfo)
	it.Attributes = []*AnnotationAttribute{}
	return it
}

func (me *AnnotationInfo) AppendAttribute(k, v string) *AnnotationAttribute {
	it := new(AnnotationAttribute)
	it.Annotation = me
	it.Key = k
	it.Value = v
	me.Attributes = append(me.Attributes, it)
	return it
}

func (me *AnnotationInfo) Clone() interface{} {
	it := new(AnnotationInfo)
	it.Name = me.Name

	it.Attributes = make([]*AnnotationAttribute, len(me.Attributes))
	for i, v := range me.Attributes {
		it.Attributes[i] = v.Clone().(*AnnotationAttribute)
		it.Attributes[i].Annotation = it
	}

	return it
}

func (me *AnnotationInfo) Get(k string) string {
	for _, it := range me.Attributes {
		if it.Key == k {
			return it.Value
		}
	}

	return ""
}
